import QtQuick 2.0

import "../../js/util.js" as Util

ACellRow {
    property alias m_niceName: m_NameText_id.text
    property var m_model
    signal acceptClicked(string phone, string sip)

    m_leftItem: Item {
        width: m_lineValue
        height: m_lineValue

        Image {
            width: parent.width*0.6
            height: parent.height*0.6
            anchors.centerIn: parent
            source: "qrc:/images/callImage/incoming_head.png"
        }
    }

    m_centerItem: Column {
        width: m_root_id.width - m_lineValue*2

        AText {
            id: m_NameText_id
            width: parent.width
            font.pointSize: 18
            elide: Text.ElideRight
            wrapMode: Text.NoWrap
            text: model.nickName === ""
                  ? (model.name === "" ? model.phone1 : model.name)
                  : model.nickName
        }

        AText {
            id: m_PhoneText_id
            width: parent.width
            font.pointSize: 16
            elide: Text.ElideRight
            wrapMode: Text.NoWrap
            text: qsTr("对方请求添加你为好友")
        }
    }

    m_rightItem: Rectangle {
        id: m_acceptItem
        width: m_lineValue
        height: m_lineValue*0.5
        color: Util.titleColor
        radius: 10

        AText {
            id: m_acceptText
            anchors.centerIn: parent
            font.pointSize: 18
            text: qsTr("接受")
            color: "#ffffff"
        }

        states: [
            State {
                when: m_mouse.pressed
                changes: [
                    PropertyChanges { target: m_acceptItem; color: "#aaaaaa" },
                    PropertyChanges { target: m_acceptText; color: "#ffffff" }
                ]
            }
        ]

        MouseArea {
            id: m_mouse
            anchors.fill: parent
            onClicked: acceptClicked(m_model.phone1, m_model.sipuri)
        }
    }
}

